using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Lesson7 : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        InputMgr.GetInstance().Open();
        ListenerMgr.GetInstance().AddTrigger<KeyCode>("onKeyDown", onKeyDown);
        ListenerMgr.GetInstance().AddTrigger<KeyCode>("onKeyUp", onKeyUp);
    }

    void onKeyDown(KeyCode keyCode)
    {
         
        switch (keyCode)
        {
            case KeyCode.W:
                Debug.LogFormat("前进");
                break;
            case KeyCode.S:
                Debug.LogFormat("后退");
                break;
            case KeyCode.A:
                Debug.LogFormat("左转");
                break;
            case KeyCode.D:
                Debug.LogFormat("右转");
                break;
        }
    }

    void onKeyUp(KeyCode keyCode)
    {
        switch (keyCode)
        {
            case KeyCode.W:
                Debug.LogFormat("停止前进");
                break;
            case KeyCode.S:
                Debug.LogFormat("停止后退");
                break;
            case KeyCode.A:
                Debug.LogFormat("停止左转");
                break;
            case KeyCode.D:
                Debug.LogFormat("停止右转");
                break;
        }
    }
}
